package com.wzq.solution;

class Solution {
    public static void rotate(int[][] matrix) {
        int n = matrix.length;
        
        for(int l=0;l<n/2;l++){

            for(int i=0;i < n-2*l-1;i++){

                int s = l;
                int s1 = n-1-l;
                int d = l+i;
                int d1 = n-1-l-i;

                int t1 = matrix[s][d];
                int t2 = matrix[d1][s];
                int t3 = matrix[s1][d1];
                int t4 = matrix[d][s1];

                int tmp = matrix[s][d];
                matrix[s][d] =  matrix[d1][s];
                matrix[d1][s] = matrix[s1][d1];
                matrix[s1][d1]= matrix[d][s1];
                matrix[d][s1] = tmp;

            }
        }

    }

    public static void main(String[] args) {
        int[][] digits = new int[][]{{5,1,9,11},{2,4,8,10},{13,3,6,7},{15,14,12,16}};
        rotate(digits);
    }
}